<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head th:include="/common/common_head::commonHead('首页')"></head>
<body class="easyui-layout">
<div data-options="region:'north'" style="height:9%;">
    <div sec:authentication="name"></div>

</div>
<div data-options="region:'west',split:true,title:'West'" style="width:10%;height: 85%">
    <div id="accordionList" class="easyui-accordion" data-options="fit:true" style="height:100%;">
    </div>
</div>
<div data-options="region:'center',title:'Center'">
    <div id="tt" data-options="fit:true" class="easyui-tabs">
        <div title="欢迎页" class="welcome">
        </div>
    </div>
</div>
<div data-options="region:'south'" style="height:6%;">
    south region
</div>
<div th:include="/common/common_js::commonJs"></div>
</body>
<script>
    $(function () {
        showLeftTree();
    });
    function showLeftTree() {
        $("#accordionList").empty();
        var i = 1;
        var data = {};
        $.ajax({
            type: "POST",
            url: "/leftTree",
            data: data,
            dataType: "json",
            success: function (data) {
                var i = 1;
                for (var o in data) {
                    $("#accordionList")
                            .accordion(
                                    "add",
                                    {
                                        title: data[o].text,
                                        content: '<div  style="overflow: auto; padding: 0px;"><ul class="easyui-tree" id="tree' + i + '"></ul></div>'
                                    });
                    var permissList = eval(data[o].children);
                    $("#tree" + i)
                            .tree({
                                data: permissList,
                                lines: true,
                                onClick: function (node) {
                                    if ($('#tt').tree('isLeaf', node.target)) {//判断是否是叶子节点
                                        if ($('#tt').tabs('exists', node.text)) {
                                            $('#tt').tabs('select', node.text);
                                            refreshTab({
                                                tabTitle: node.text,
                                                url: node.attributes.url
                                            });
                                        } else {
                                            var content = '<iframe scrolling="no" frameborder="0"  src="'+node.attributes.url+'" style="width:100%;height:100%;"></iframe>';
                                            $('#tt')
                                                    .tabs(
                                                            'add',
                                                            {
                                                                title: node.text,
                                                                closable: true,
                                                                content: content,
                                                                id: node.id
                                                            });

                                        }
                                    }
                                }
                            });
                    i++;
                }
            }
        });
    }
</script>
</html>
